﻿//DONE, tested and good - Sven 2/25/2010
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

namespace IRC4N00bz {
    public sealed class PingSender : Plugin {
        static string PING = "PING :";
        private Thread th;

        Bot bot;
        public PingSender(Bot bot):base(bot) {
            this.bot = bot;
            th = new Thread(new ThreadStart(this.Run));
        }

        /// <summary>
        /// Start the ping sender thread.
        /// </summary>
        public void Start() {
            th.Start();
        }

        private void Run() {
            while (true) {
                try {
                    bot.RFC_SendRaw(PING + Bot.SERVER);
                    Thread.Sleep(20000);
                } catch (Exception err) {
                    //TODO: Log errors here?
                }
            }
        }
    }
}
